package cn.iocoder.yudao.module.infra.service.face;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.infra.controller.admin.face.vo.FaceRecordPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.face.FaceRecordDO;
import cn.iocoder.yudao.module.infra.dal.mysql.face.FaceRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 人脸记录 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class FaceRecordServiceImpl implements FaceRecordService {

    @Resource
    private FaceRecordMapper faceRecordMapper;

    @Override
    public Long createRecord(FaceRecordDO faceRecord) {
        faceRecordMapper.insert(faceRecord);
        return faceRecord.getId();
    }

    @Override
    public void updateRecord(FaceRecordDO faceRecord) {
        faceRecordMapper.updateById(faceRecord);
    }

    @Override
    public void deleteRecord(Long id) {
        faceRecordMapper.deleteById(id);
    }

    @Override
    public FaceRecordDO getRecordByUserId(Long userId) {
        return faceRecordMapper.selectByUserId(userId);
    }

    @Override
    public FaceRecordDO getRecordByFaceToken(String faceToken) {
        return faceRecordMapper.selectByFaceToken(faceToken);
    }

    @Override
    public FaceRecordDO getRecord(Long id) {
        return faceRecordMapper.selectById(id);
    }

    @Override
    public PageResult<FaceRecordDO> getRecordPage(FaceRecordPageReqVO pageReqVO) {
        return faceRecordMapper.selectPage(pageReqVO);
    }

}